﻿using Modules.Views;
using Prism.Ioc;
using Prism.Modularity;
using Prism.Unity;
using System.IO;
using System.Windows;

namespace Modules
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : PrismApplication
    {
        protected override Window CreateShell()
        {
            return Container.Resolve<MainWindow>();
        }

        protected override void RegisterTypes(IContainerRegistry containerRegistry)
        {

        }

        protected override IModuleCatalog CreateModuleCatalog()
        {
            return new DirectoryModuleCatalog() { ModulePath = @".\Modules" };

            //加载多个文件夹的方式为(即加载一个目录下的多个文件夹)

            //ModuleCatalog res = new ModuleCatalog();
            //string path = @".\Modules";
            //// 获取所有直接子文件夹
            //string[] directories = Directory.GetDirectories(path);

            //List<ModuleInfo> modules = new List<ModuleInfo>();
            //foreach (string dir in directories)
            //{
            //    DirectoryModuleCatalog moduleCatalog = new DirectoryModuleCatalog() { ModulePath = dir };
            //    moduleCatalog.Initialize();
            //    foreach (var item in moduleCatalog.Modules)
            //    {
            //        res.AddModule(item);
            //    }
            //}
            //return res;
        }
    }
}
